円グラフ
Contents
1. 円グラフ¶
1.1. 概要¶
円グラフとは,
1.2. Plotlyによる作図方法¶
1.3. MADB Labを用いた作図例¶
1.3.1. 下準備¶
import pandas as pd
import plotly.express as px
import warnings
warnings.filterwarnings('ignore')
# 前処理の結果,以下に分析対象ファイルが格納されていることを想定
PATH_DATA = '../../data/preprocess/out/episodes.csv'
# Jupyter Book用のPlotlyのrenderer
RENDERER = 'plotly_mimetype+notebook'
def show_fig(fig):
"""Jupyter Bookでも表示可能なようRendererを指定"""
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
fig.show(renderer=RENDERER)
df = pd.read_csv(PATH_DATA)
1.3.2. 雑誌別の合計作品数¶
df_plot = \
df.groupby('mcname')['cname'].nunique().reset_index()
df_plot = df_plot.sort_values('mcname', ignore_index=True)
fig = px.pie(
df_plot, values='cname', names='mcname',
color_discrete_sequence= px.colors.diverging.Portland,
title='雑誌別の合計作品数')
show_fig(fig)
1.3.3. 雑誌別の合計作者数¶
df_plot = \
df.groupby('mcname')['creator'].nunique().reset_index()
df_plot = df_plot.sort_values('mcname', ignore_index=True)
fig = px.pie(
df_plot, values='creator', names='mcname',
color_discrete_sequence= px.colors.diverging.Portland,
title='雑誌別の合計作者数')
show_fig(fig)